package com.flyco.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.flyco.modules.system.entity.SysOpenAccount;
import com.flyco.modules.system.mapper.SysOpenAccountMapper;
import com.flyco.modules.system.service.ISysOpenAccountService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 开发平台账户配置表
 * @Author: flyco
 * @Date:   2021-07-26
 * @Version: V1.0
 */
@Service
public class SysOpenAccountServiceImpl extends ServiceImpl<SysOpenAccountMapper, SysOpenAccount> implements ISysOpenAccountService {

    @Override
    public SysOpenAccount getAccountByPartnerAndBizCode(Long partnerId, String bizCode, String source) {
        LambdaQueryWrapper<SysOpenAccount> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysOpenAccount::getPartnerId, partnerId);
        queryWrapper.eq(SysOpenAccount::getBizCode, bizCode);
        queryWrapper.eq(SysOpenAccount::getSource, source);
        queryWrapper.eq(SysOpenAccount::getCancelFlag, 0);
        List<SysOpenAccount> accounts = this.list(queryWrapper);
        if (accounts.size() > 0) return accounts.get(0);
        return null;
    }
}
